package com.kitten.vectorstoresearch.controller;

import com.kitten.vectorstoresearch.reader.*;
import jakarta.annotation.Resource;
import org.springframework.ai.document.Document;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author kitten
 */
@RestController
@RequestMapping("/read")
public class ReaderController {

    // ==================== Text Reader ======================
    @Resource
    private MyTextReader textReader;

    @GetMapping(value = "/txt")
    public List<Document> readText() {
        return textReader.loadText();
    }

    /**
     * 对于大文件 txt, 考虑分割读取
     * @return
     */
    @GetMapping(value = "/txt2")
    public List<Document> readText2() {
        return textReader.loadTextAndSplit();
    }
    // ==================== Json Reader ======================
    @Resource
    private MyJsonReader jsonReader;

    @GetMapping(value = "/json")
    public List<Document> readJson() {
        return jsonReader.loadJson();
    }

    // ==================== Md Reader ======================
    @Resource
    private MyMarkdownReader markdownReader;

    @GetMapping(value = "/md")
    public List<Document> readMarkdown() {
        return markdownReader.loadMarkdown();
    }

    // ==================== Htm Reader ======================
    @Resource
    private MyHtmReader htmlReader;

    @GetMapping(value = "/html")
    public List<Document> readHtml() {
        return htmlReader.loadHtml();
    }

    // ==================== PDF Reader ======================
    @Resource
    private MyPdfReader pdfReader;

    @GetMapping(value = "/pdf")
    public List<Document> readPdf() {
        return pdfReader.getDocsFromPdf();
    }

    // ==================== Word Reader By Tika ======================
    @Resource
    private MyTikaWordReader tikaWordReader;

    @GetMapping(value = "/word")
    public List<Document> readWord() {
        return tikaWordReader.loadWord();
    }

    // ==================== PPT Reader By Tika ================
    @Resource
    private MyTikaPptReader tikaPptReader;

    @GetMapping(value = "/ppt")
    public List<Document> readPpt() {
        return tikaPptReader.loadPpt();
    }


}
